<template>
  <div class="simulation-wrapper">
    <div class="simulation">
      <div class="simulation-header">
        <i class="icon" :class="iconName"></i>
        <div class="title">{{ title }}</div>
      </div>
      <div class="simulation-body">
        <Slider
          v-show="growthState"
          v-model="currentGrowthLevel"
          style="padding: 0 12px"
          :step="0.05"
          :min="0"
          :max="1"
          :marks="marks"
          show-tip="never"
          @on-change="setGrowthLevelSimulation"
        ></Slider>
        <Slider
          v-show="waterState"
          v-model="currentWaterLevel"
          style="padding: 0 12px"
          :step="0.05"
          :min="0"
          :max="1"
          :marks="marks"
          show-tip="never"
          @on-change="setWaterLevelSimulation"
        ></Slider>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "",
  data() {
    return {
      currentWaterLevel: null,
      currentGrowthLevel: null,
      marks: {},
      waterState: null,
      growthState: null,
    };
  },
  props: {
    iconName: String,
    title: String,
  },
   watch: {
    title: {
      handler(n, o) {
        console.log(n);
        if (n === "生长") {
      this.growthState = true;
      this.waterState = false;
      this.marks = {
        0: {
          label: this.$createElement("span", "0"),
        },
        0.25: {
          label: this.$createElement("span", "5"),
        },
        0.5: {
          label: this.$createElement("span", "10"),
        },
        0.75: {
          label: this.$createElement("span", "15"),
        },
        1: {
          label: this.$createElement("span", "20年后"),
        },
      };
    } else {
      this.growthState = false;
      this.waterState = true;
      this.marks = {
        0.01: {
          label: this.$createElement("span", "枯季\n(158m)"),
        },
        0.34: {
          label: this.$createElement("span", "洪季\n(170m)"),
        },
        0.67: {
          label: this.$createElement("span", "十年一遇\n(180m)"),
        },
        1: {
          label: this.$createElement("span", "百年一遇\n(190m)"),
        },
      };
    }
      },
      immediate: true,
      deep: true,
    },
  },
  created() {
    
  },
  methods: {
    setWaterLevelSimulation() {
      this.$emit("on-change", this.currentWaterLevel);
    },
    setGrowthLevelSimulation() {
      this.$emit("on-change", this.currentWaterLevel);
    },
  },
};
</script>

<style lang="" scoped>
</style>